/**********************************************************************
  The MIT License (MIT)
  Copyright (c) 2012 sunriseyuen

  Permission is hereby granted, free of charge, to any person obtaining
  a copy of this software and associated documentation files
  (the "Software"), to deal in the Software without restriction,
  including without limitation the rights to use, copy, modify, merge,
  publish, distribute, sublicense, and/or sell copies of the Software,
  and to permit persons to whom the Software is furnished to do so,
  subject to the following conditions:

  The above copyright notice and this permission notice shall be included
  in all copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
  THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 ***********************************************************************/

#region Using directives
using System;
using System.Text;
using System.IO;
using System.Xml;
using System.Collections;		   
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Reflection;
using System.Web;
using System.Web.UI;

using Muki.Framework;
using Muki.Framework.UI;
using Muki.Framework.Util;
using Muki.Framework.Business;
using Muki.Entity;

using Dot.StreamObject;

#endregion

namespace Muki.UserPanel
{
	public class UID22008AUI : BaseAction
	{
		public UID22008AUI()
		{
		}
		
		public override void OnPreview()
		{
			_UID22008AM.FileName  = "UID22008A";
			_UID22008AM.Trans     = this.Trans;
			UID22008AE _NewEntity = _UID22008AM.Process(_UID22008AV.Entity);

			_NewEntity=_UID22008AM.Convert(_NewEntity);
			_UID22008AV.Entity             = _NewEntity;
		
		}
		
		public override void OnSearch()
		{
			_UID22008AM.FileName  = "UID22008A";
			_UID22008AM.Trans     = this.Trans;
			UID22008AE _NewEntity = _UID22008AM.Process(_UID22008AV.Entity);

			_UID22008AV.Entity             = _NewEntity;

		}

		public override void Process()
		{
			try
			{
				checked
				{

					this.Trans                = new StreamContext(this.DbName);
					_UID22008AM.Trans       = this.Trans;
					_UID22008AM.APP_PATH    = this.APP_PATH;
					_UID22008AM.ZZLOGON_SSD = _UID22008AV.ZZLOGON_SSD;
					_UID22008AM.Initialize();

					base.Process();

					ZZTrace.Debug(ZFILE_NAME,"Process");

				}
			}
			catch (LogisticException e)
			{
				_UID22008AV.Exceptions.Add(e);
				ZZTrace.Error(ZFILE_NAME,e);

				try
				{
					this.Trans.RollBack();
				}
				catch (Exception Ex)
				{
					ZZTrace.Error(ZFILE_NAME,Ex);
				}
			}
			catch (Exception e)
			{
				ZZTrace.Error(ZFILE_NAME,e);
				try
				{
					this.Trans.RollBack();
				}
				catch (Exception)
				{
				}
			}
			finally
			{
				this.Trans.Close();
				ZZTrace.Debug(ZFILE_NAME,"Finally");
			}

		}

		//Framework
		public override void OnInit(HttpContext  objHttpContext)		
		{
			_UID22008AV.OnInit(objHttpContext);
			this.DbName              = _UID22008AV.DbName;
			this.ZZVIEW_STATUS_CODE  = _UID22008AV.ZZVIEW_STATUS_CODE;
			this.ZZVIEW_MODE_CODE    = _UID22008AV.ZZVIEW_MODE_CODE;
			this.ZZEventArgs         = _UID22008AV.ZZEventArgs;
	
			_UID22008AM.ZZLOGON_LANG = _UID22008AV.ZZLOGON_LANG;
			_UID22008AM.ZZLOGON_SSD = _UID22008AV.ZZLOGON_SSD;
			_UID22008AM.ZZLOGON_ID  = _UID22008AV.ZZLOGON_ID;
			_UID22008AM.DbName      = _UID22008AV.DbName;

			_UID22008AV.APP_PATH    = this.APP_PATH;
			_UID22008AV.setValue();
		}

		public override void Render(HtmlTextWriter objTextWriter)
		{
			_UID22008AV.getValue();
			_UID22008AV.Render(objTextWriter);

		}

		const string ZFILE_NAME = "UID22008AC";

		private UID22008AM   _UID22008AM           = new UID22008AM();
		private UID22008AV      _UID22008AV = new UID22008AV();
	}
}
